//
// PathFinder.cs
//
// Copyright (C) 2008 Lukas Lipka <lukaslipka@gmail.com>

using System;
using System.IO;

namespace Dashboard.Util
{
	public static class PathFinder
	{
		static private string user_data_dir = null;
		static private string backend_user_data_dir = null;

		public static string Home
		{
			get { return Environment.GetFolderPath (Environment.SpecialFolder.Personal); }
		}

		public static string Installation
		{
			get { return ConfigureDefines.InstallDirectory; }
		}

		public static string Components 
		{
			get { return Path.Combine (ConfigureDefines.InstallDirectory, "Dashboard.Engine.Components"); }
		}

		public static string UserData
		{
			get { 
				if (!String.IsNullOrEmpty (user_data_dir))
					return user_data_dir;
#if WINDOWS
				user_data_dir = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData), "Dashboard");
#else
				user_data_dir = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.Personal), ".dashboard");				
#endif
				if (!Directory.Exists (user_data_dir))
					Directory.CreateDirectory (user_data_dir);

				return user_data_dir;
			}
		}

		public static string BackendUserData
		{
			get {
				if (!String.IsNullOrEmpty (backend_user_data_dir))
					return backend_user_data_dir;

				backend_user_data_dir = Path.Combine (UserData, "Backends");

				if (!Directory.Exists (backend_user_data_dir))
					Directory.CreateDirectory (backend_user_data_dir);				

				return backend_user_data_dir;
			}
		}
	}
}
